using Unity.VisualScripting;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Load DataTable")]
    [UnitSurtitle("Update")]
    public sealed class LoadDataTableUpdate : FrameworkEventUnit<LoadDataTableUpdateEventArgs>
    {
        protected override int EventId => LoadDataTableUpdateEventArgs.EventId;
        protected override string HookName => UGFHookNames.LoadDataTableUpdate;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DataTableAssetName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Progress
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            DataTableAssetName = ValueOutput<string>(nameof(DataTableAssetName));
            Progress = ValueOutput<float>(nameof(Progress));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, LoadDataTableUpdateEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(DataTableAssetName, args.DataTableAssetName);
            flow.SetValue(Progress, args.Progress);
            flow.SetValue(UserData, args.UserData);
        }
    }
}